//package com.bang.study.spring.config;
//
//import com.bang.study.spring.bean.Blue;
//import com.bang.study.spring.condition.LinuxCondition;
//import com.mchange.v2.c3p0.ComboPooledDataSource;
//import com.sun.org.apache.regexp.internal.RE;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
//import org.springframework.context.annotation.*;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.transaction.PlatformTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//import org.springframework.transaction.annotation.Transactional;
//
//import javax.sql.DataSource;
//import java.beans.PropertyVetoException;
//
///**
// * @ClassName: BeanConfig
// * @author: BANG
// * @Date: 2019/11/13 10:11
// * @Version: 1.0
// * @Modified By:
// * @Desc: TODO
// */
//@Configuration
//@PropertySource(value = "classpath:jdbc.properties")
//@EnableTransactionManagement
//public class BeanConfig {
//
//
//    @Primary
//    @Bean(value = "blues", initMethod = "init", destroyMethod = "destory")
////    @Conditional(LinuxCondition.class)
//    public Blue blue() {
//        return new Blue();
//    }
//
//
//    @Value("${spring.datasource.airobot.username}")
//    private String user;
//
//    @Value("${spring.datasource.airobot.password}")
//    private String password;
//
//    @Value("${spring.datasource.airobot.driver-class-name}")
//    private String driverclassname;
//
//    @Value("${spring.datasource.airobot.jdbc-url}")
//    private String jdbcUrl;
//
//    @Bean
//    DataSource dataSource() throws PropertyVetoException {
//        ComboPooledDataSource dataSource = new ComboPooledDataSource();
//        dataSource.setUser(user);
//        dataSource.setPassword(password);
//        dataSource.setDriverClass(driverclassname);
//        dataSource.setJdbcUrl(jdbcUrl);
//        return dataSource;
//    }
//
//    @Bean
//    JdbcTemplate jdbcTemplate() throws Exception{
//        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource());
//        return jdbcTemplate;
//    }
//
//    //注册事务管理器在容器中
//    @Bean
//    public PlatformTransactionManager transactionManager() throws Exception{
//        return new DataSourceTransactionManager(dataSource());
//    }
//
//}
